package com.example.xjtuse_pc.mobilesafe.LostGuid;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.example.xjtuse_pc.mobilesafe.LastFindActivity;
import com.example.xjtuse_pc.mobilesafe.R;

public class Setup4Activity extends BaseSetupAcitivity {
private SharedPreferences sp;
    private CheckBox cb_proteting;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setup4);
        sp=getSharedPreferences("config",MODE_PRIVATE);
        cb_proteting = (CheckBox) findViewById(R.id.cb_proteting);
        boolean  protecting = sp.getBoolean("protecting", false);
        if(protecting){
            //手机防盗已经开启了
            cb_proteting.setText("手机防盗已经开启");
            cb_proteting.setChecked(true);
        }else{
            //手机防盗没有开启
            cb_proteting.setText("手机防盗没有开启");
            cb_proteting.setChecked(false);

        }
        cb_proteting.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked) {
                    cb_proteting.setText("手机防盗已经开启");
                } else {
                    cb_proteting.setText("手机防盗没有开启");
                }
                SharedPreferences.Editor ed = sp.edit();
                ed.putBoolean("protecting", isChecked);
                ed.commit();
            }
        });

    }

    @Override
    public void showNext() {
        SharedPreferences.Editor editor = sp.edit();
        editor.putBoolean("configed", true);
        editor.commit();
        Intent intent = new Intent(Setup4Activity.this, LastFindActivity.class);
        startActivity(intent);
        finish();
        overridePendingTransition(R.anim.tran_in, R.anim.tran_out);
    }

    @Override
    public void showPre() {
        Intent intent = new Intent(Setup4Activity.this, Setup3Activity.class);
        startActivity(intent);
        finish();
        overridePendingTransition(R.anim.retran_in, R.anim.retran_out);


    }
}
